package com.example.adms.role.controller;

import com.example.adms.role.dto.SetPermParams;
import com.example.adms.role.service.PermissionService;
import com.example.adms.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/perm")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    /**
     * 获取权限列表
     * @return
     */
    @GetMapping("/getPermList")
    public Result getPermList(Integer roleId){
        return permissionService.getPermList(roleId);
    }

    /**
     * 设置角色权限
     * @return
     */
    @PostMapping("/setPermByRoleId")
    public Result setPermByRoleId(@RequestBody SetPermParams setPermParams){
        return permissionService.setPermByRoleId(setPermParams);
    }

    /**
     * 根据角色id获取拥有的权限
     * @param roleId
     * @return
     */
    @GetMapping("/getPermListByRoleId")
    public Result getPermListByRoleId(Integer roleId){
        return permissionService.getPermListByRoleId(roleId);
    }

}
